<template>
  <nav class="navbar navbar-default navigate-main" role="navigation">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse"
                data-target="#example-navbar-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand navigate-title" href="/user/">
          <i class="el-icon-s-home"></i>电子病历管理系统</a>
      </div>
      <div class="collapse navbar-collapse" id="example-navbar-collapse">
        <ul class="nav navbar-nav navbar-right">
          <li class="dropdown navigate-menu">
            <a><i class="el-icon-phone"></i>{{$store.state.phoneNumber}}</a>
          </li>
          <li class="dropdown">
            <a class="dropdown-toggle navigate-menu" data-toggle="dropdown">
              {{$store.state.userModules.userInfo.realName}} <b class="caret"></b>
            </a>
            <ul class="dropdown-menu navigate-menu">
              <li data-func="userinfo"><a class="navigate-menu-title" @click.stop="gotoUserInfo">个人中心</a></li>
              <li data-func="deluser"><a class="navigate-menu-title" @click.stop="clearUserInfo">账户注销</a></li>
              <li data-func="logout"><a class="navigate-menu-title" @click.stop="logout">退出登录</a></li>
            </ul>
          </li>
        </ul>
      </div>
    </div>
  </nav>
</template>
<script>

export default {
  methods:{
    clearUserInfo(){
      this.$util.errorMessage("暂时不支持该功能")
    },
    gotoUserInfo(){
      this.$router.push({path:'/user/userinfo'})
    },
    async logout(){
      const result = await this.$store.dispatch("logout")
      result?this.$router.replace("/user/login"):null
    }
  }
}
</script>

